package com.pets.controller;


import com.pets.pojo.FinancialManagement;
import com.pets.pojo.MyCourse;
import com.pets.service.IMyCourseService;
import com.pets.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 我的课程 前端控制器
 * </p>
 *
 * @author 小陳同學
 * @since 2024-05-14
 */
@RestController
@RequestMapping("/my-course")
@Api(tags = "我的课程")
public class MyCourseController {

    @Autowired
    private IMyCourseService myCourseService;

    @ApiOperation("预约课程")
    @PostMapping
    public Result register(@RequestBody MyCourse myCourse) {
        return myCourseService.register(myCourse);
    }

    @ApiOperation("预约课程分页查询")
    @GetMapping("/list")
    public Result list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       @ApiParam(value = "当前登陆人id")@RequestParam(required = true) Integer userId) {
        return myCourseService.selectPage(page, pageSize, userId);
    }


    @ApiOperation("根据id取消预约")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return myCourseService.deleteById(id);
    }
}
